import HTTP from '../utils/http';
import { API } from '../config/config';
import { Message } from 'element-ui';
import { axiosMessageShow } from '@/utils/tools';
const PROJECT = API.PROJECT;

export default class ProjectClass extends HTTP{
    findType(id) {
        return new Promise((resolve)=>{
          this.axiosPost({
              url:TYPE.TYPE_GET,
              data:id,
              success(data){
                  
                  resolve(data.data)
              },error(error){
                  Message({
                      message:error,
                      type:'error'
                  })
              }
          })
        })  
      }
      destroyType(id){
          return new Promise((resolve)=>{
              this.axiosPost({
                  url:TYPE.TYPE_DESTROY,
                  data:id,
                  success(data){
                      axiosMessageShow(data);
                      resolve(data)
                  },error(error){
                      Message({
                          message:error,
                          type:'error'
                      })
                  }
              })
            })
      }
      createType(data){
          return new Promise((resolve)=>{
              this.axiosPostFromdata({
                  url:TYPE.TYPE_CREATE,
                  data,
                  success(data){
                      axiosMessageShow(data);
                      resolve(data)
                  },error(error){
                      Message({
                          message:error,
                          type:'error'
                      })
                  }
              })
            }) 
      }
      updateType(data){
          return new Promise((resolve)=>{
              this.axiosPostFromdata({
                  url:TYPE.TYPE_UPDATE,
                  data,
                  success(data){
                      axiosMessageShow(data);
                      resolve(data)
                  },error(error){
                      Message({
                          message:error,
                          type:'error'
                      })
                  }
              })
            }) 
      }
      changeStatusType(){
          
      }
}

